<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of VMT_LoadMap</title>
  <meta name="keywords" content="VMT_LoadMap">
  <meta name="description" content="This routine loads a map file from either a text file or a .mat file.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- ../menu.html trunk --><!-- menu.html depreciated -->
<h1>VMT_LoadMap
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>This routine loads a map file from either a text file or a .mat file.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function Map = VMT_LoadMap(filetype,coord,varargin); </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> This routine loads a map file from either a text file or a .mat file. 

 Input:  filetype = 'txt' for a text file (2 col (x,y), no headers); 'mat' for a matlab data file 
        coord    = 'UTM' for UTM coordinates or 'LL' for latitude, longitude (in dec deg)
        zone     = zone for UTM coordinates (Removed from Input--will be
        determined from the data automatically)
 
 
 P.R. Jackson, 12-9-08
 Last Modified: Frank L. Engel, 7/25/2013</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function Map = VMT_LoadMap(filetype,coord,varargin);</a>
0002 <span class="comment">% This routine loads a map file from either a text file or a .mat file.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% Input:  filetype = 'txt' for a text file (2 col (x,y), no headers); 'mat' for a matlab data file</span>
0005 <span class="comment">%        coord    = 'UTM' for UTM coordinates or 'LL' for latitude, longitude (in dec deg)</span>
0006 <span class="comment">%        zone     = zone for UTM coordinates (Removed from Input--will be</span>
0007 <span class="comment">%        determined from the data automatically)</span>
0008 <span class="comment">%</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% P.R. Jackson, 12-9-08</span>
0011 <span class="comment">% Last Modified: Frank L. Engel, 7/25/2013</span>
0012 
0013 <span class="keyword">if</span> ~isempty(varargin)
0014     guiprefs = varargin{1};
0015 <span class="keyword">else</span>
0016     guiprefs = [];
0017 <span class="keyword">end</span>
0018 
0019 <span class="keyword">switch</span> filetype
0020     <span class="keyword">case</span>{<span class="string">'txt'</span>}
0021         [file,shorepath] = uigetfile(<span class="keyword">...</span>
0022             {<span class="string">'*.txt;*.csv'</span>,<span class="string">'All Text Files'</span>; <span class="string">'*.*'</span>,<span class="string">'All Files'</span>},<span class="keyword">...</span>
0023             <span class="string">'Select Map Text File'</span>,<span class="keyword">...</span>
0024             fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file));
0025         
0026 <span class="comment">%         defaultpath = 'C:\';</span>
0027 <span class="comment">%         shorepath = [];</span>
0028 <span class="comment">%         if 0 %exist('VMT\LastDir.mat') == 2</span>
0029 <span class="comment">%             load('VMT\LastDir.mat');</span>
0030 <span class="comment">%             if exist(shorepath) == 7</span>
0031 <span class="comment">%                 [file,shorepath] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Map Text File',shorepath);</span>
0032 <span class="comment">%             else</span>
0033 <span class="comment">%                 [file,shorepath] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Map Text File',defaultpath);</span>
0034 <span class="comment">%             end</span>
0035 <span class="comment">%         else</span>
0036 <span class="comment">%             [file,shorepath] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Map Text File',defaultpath);</span>
0037 <span class="comment">%         end</span>
0038         
0039         <span class="keyword">if</span> ischar(file) <span class="comment">% User did not hit cancel</span>
0040             infile = [shorepath file];
0041             <span class="comment">%disp('Loading Map File...' );</span>
0042             <span class="comment">%disp(infile);</span>
0043             data = dlmread(infile);
0044             <span class="keyword">switch</span> coord
0045                 <span class="keyword">case</span>{<span class="string">'LL'</span>}
0046                     <span class="comment">% convert lat long into UTMe and UTMn</span>
0047                     [Map.UTMe,Map.UTMn,Map.UTMzone] = deg2utm(data(:,1),data(:,2));
0048                 <span class="keyword">case</span>{<span class="string">'UTM'</span>}
0049                     Map.UTMe = data(:,1);
0050                     Map.UTMn = data(:,2);
0051                     <span class="comment">%Map.UTMzone = zone;</span>
0052             <span class="keyword">end</span>
0053         <span class="keyword">else</span>
0054             Map = [];
0055             <span class="keyword">return</span>
0056         <span class="keyword">end</span>
0057                 
0058     <span class="keyword">case</span>{<span class="string">'mat'</span>} <span class="comment">%assumes Map data structure (above) is present</span>
0059         [file,shorepath] = uigetfile(<span class="keyword">...</span>
0060             <span class="string">'*.mat'</span>,<span class="keyword">...</span>
0061             <span class="string">'Select Map File'</span>,<span class="keyword">...</span>
0062             fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file));
0063         
0064         <span class="keyword">if</span> ischar(file) <span class="comment">% User did not hit cancel</span>
0065             infile = [shorepath file];
0066             <span class="comment">%disp('Loading Map File...' );</span>
0067             <span class="comment">%disp(infile);</span>
0068             load(infile);
0069         <span class="keyword">else</span>
0070             Map = [];
0071             <span class="keyword">return</span>
0072         <span class="keyword">end</span>
0073 <span class="keyword">end</span>
0074 
0075 Map.infile = infile;
0076 
0077 <span class="comment">%Save the shorepath</span>
0078 <span class="comment">% if exist('LastDir.mat') == 2</span>
0079     <span class="comment">% save('LastDir.mat','shorepath','-append')</span>
0080 <span class="comment">% else</span>
0081     <span class="comment">% save('LastDir.mat','shorepath')</span>
0082 <span class="comment">% end</span></pre></div>
<hr><address>Generated on Wed 04-Jun-2014 14:21:02 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>